/*
 * kroki.c
 *
 *  Created on: 2011-05-25
 *       Author: Jakub Chelim
 */
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdlib.h>

#include "kroki.h"

int8_t kr;

void kroki_stop(void){
	switch (kr){
	case 1:		KROK1;break;
	case 2:		KROK2;break;
	case 3:		KROK3;break;
	case 4:		KROK4;break;
	case 5:		KROK5;break;
	case 6:		KROK6;break;
	case 7:		KROK7;break;
	case 8:		KROK8;break;
	}
}

void kroki_prawo(void) {

	if( !(kr%2) ) {kr++;}
	else{
		kr+=2;
	}
	if( kr > 7 ) kr=1;
	switch (kr){
	case 1:		KROK1;break;
	case 3:		KROK3;break;
	case 5:		KROK5;break;
	case 7:		KROK7;break;
	}
}

void kroki_lewo(void) {

	if( !(kr%2) ) {kr--;}
	else{
		kr-=2;
	}
	if( kr < 1 ) kr=7;
	switch (kr){
	case 1:		KROK1;break;
	case 3:		KROK3;break;
	case 5:		KROK5;break;
	case 7:		KROK7;break;
	}
}

void polkroki_prawo(void) {

	if( ++kr > 8 ) kr=1;
	switch (kr){
	case 1:		KROK1;break;
	case 2:		KROK2;break;
	case 3:		KROK3;break;
	case 4:		KROK4;break;
	case 5:		KROK5;break;
	case 6:		KROK6;break;
	case 7:		KROK7;break;
	case 8:		KROK8;break;
	}
}

void polkroki_lewo(void) {

	if( --kr < 1 ) kr=8;
	switch (kr){
	case 1:		KROK1;break;
	case 2:		KROK2;break;
	case 3:		KROK3;break;
	case 4:		KROK4;break;
	case 5:		KROK5;break;
	case 6:		KROK6;break;
	case 7:		KROK7;break;
	case 8:		KROK8;break;
	}
}
